[vlc-devel] commit: Drop a const on a static array and misc cleanup. (JP Dinger )

git version control git at videolan.org
Fri Jul 31 18:28:11 CEST 2009


vlc | branch: master | JP Dinger <jpd at videolan.org> | Fri Jul 31 18:26:16 2009 +0200| [d0e62402b793afeb4b8fe0c0ea04ea1615d993d3] | committer: JP Dinger 

Drop a const on a static array and misc cleanup.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d0e62402b793afeb4b8fe0c0ea04ea1615d993d3
---

 modules/access/dvb/scan.c |   20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/modules/access/dvb/scan.c b/modules/access/dvb/scan.c
index 2d37c0f..4fb409a 100644
--- a/modules/access/dvb/scan.c
+++ b/modules/access/dvb/scan.c
@@ -146,10 +146,9 @@ void scan_Clean( scan_t *p_scan )
 static int ScanDvbCNextFast( scan_t *p_scan, scan_configuration_t *p_cfg, double *pf_pos )
 {
     msg_Dbg( p_scan->p_obj, "Scan index %"PRId64, p_scan->i_index );
-    /* values from dvb-scan utils frequency-files, sorted
-     * by how often they appear, hopefully speedups finding
-     * services */
-    static int frequencies[] = {
+    /* Values taken from dvb-scan utils frequency-files, sorted by how
+     * often they appear. This hopefully speeds up finding services. */
+    static const unsigned short frequencies[] = {
      410, 426, 418, 394, 402, 362,
      370, 354, 346, 442, 434, 386,
      378, 450, 306, 162, 154, 474,
@@ -170,18 +169,15 @@ static int ScanDvbCNextFast( scan_t *p_scan, scan_configuration_t *p_cfg, double
      163, 155, 147, 146, 143, 139,
      131, 123, 121
     };
+    enum { num_frequencies = (sizeof(frequencies)/sizeof(*frequencies)) };
 
-    if( p_scan->i_index < (sizeof(frequencies)/sizeof(int)) )
+    if( p_scan->i_index < num_frequencies )
     {
         p_cfg->i_frequency = 1000000 * ( frequencies[ p_scan->i_index ] );
+        *pf_pos = (double)p_scan->i_index / num_frequencies;
+        return VLC_SUCCESS;
     }
-    else
-    {
-        return VLC_EGENERIC;
-    }
-    *pf_pos = (double)p_scan->i_index / (sizeof(frequencies)/sizeof(int));
-    return VLC_SUCCESS;
-
+    return VLC_EGENERIC;
 }
 
 static int ScanDvbTNextExhaustive( scan_t *p_scan, scan_configuration_t *p_cfg, double *pf_pos )




More information about the vlc-devel mailing list